package com.zr.daoImpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.zr.dao.RejectDaoljc;
import com.zr.util.JDBCUtil;

public class RejectDaoImplljc implements RejectDaoljc{
	//删除申请表中的数据
	@Override
	public boolean deleteapply(int id,Connection con) {
		boolean flag = false;
		StringBuffer sql = new StringBuffer("");
		sql.append(" DELETE FROM applyscore");
		sql.append(" WHERE applyscore.id=?");
		try {
			PreparedStatement pst = con.prepareStatement(sql.toString());
			pst.setInt(1, id);
			int i = pst.executeUpdate();
			if(i>0){
				flag=true;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return flag;
	}
	//在管理员日志表中添加日志
	@Override
	public boolean insertBlog(int sid, String tname, String cname, String score, String zt, String sj, String newsj,
			String nr, Connection con) {
		boolean flag = false;
		StringBuffer sql = new StringBuffer();
		sql.append(" insert into blog (sid,tname,cname,score,zt,sqsj,sj,nr)");
		sql.append(" values(?,?,?,?,?,?,?,?)");
		try {
			PreparedStatement pst = con.prepareStatement(sql.toString());
			pst.setInt(1, sid);
			pst.setString(2, tname);
			pst.setString(3, cname);
			pst.setString(4, score);
			pst.setString(5, zt);
			pst.setString(6, sj);
			pst.setString(7, newsj);
			pst.setString(8, nr);
			int i  = pst.executeUpdate();
			if(i>0){
				flag = true;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return flag;
	}
	//在教师日志表中添加数据
	@Override
	public boolean insertTblog(int sid, String tname, String sname, String cname, String score, String zt, String sqsj,
			String sj, String nr, Connection con) {
		boolean flag = false;
		StringBuffer sql = new StringBuffer();
		sql.append(" insert into teablog (sid,tname,sname,cname,score,zt,sqsj,sj,nr)");
		sql.append(" values(?,?,?,?,?,?,?,?,?)");
		try {
			PreparedStatement pst = con.prepareStatement(sql.toString());
			pst.setInt(1, sid);
			pst.setString(2, tname);
			pst.setString(3, sname);
			pst.setString(4, cname);
			pst.setString(5, score);
			pst.setString(6, zt);
			pst.setString(7, sqsj);
			pst.setString(8, sj);
			pst.setString(9, nr);
			int i  = pst.executeUpdate();
			if(i>0){
				flag = true;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return flag;
	}

}
